package com.huonan.component.thread.functions.suppliers;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static java.lang.System.out;

/**
 * 无需输入，只有输出
 * 场景：
 * 1.延迟触发
 * 2.常量获取
 */
public class SupplierTest {

    @Test
    public void test1() {
        Supplier<List<Integer>> supplier = () -> Arrays.asList(1, 2, 3, 4, 5);

        List<Integer> result = supplier.get()
                .stream()
                .filter(num -> num % 2 == 0)
                .collect(Collectors.toList());

        out.println(result); // 输出：[2, 4]
    }


    @Test
    public void test2(){

        Class<Long> longClass = Long.class;
        Class<Long> longClass1 = long.class;
    }
}
